home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 132_01 / ser6809 < prev    next >
Text File  |  1985-08-19  |  2KB  |  70 lines

  1. ;+
  2. ;    Serial Input routine for the 6809
  3. ;    I/O port configured for Radio Shack color computer
  4. ;-
  5. bitime    =    0x176    ;Time constant for 1200 baud bit interval
  6. halfbit    =    0x29    ; 1/2 bit time for center bit sync
  7. IPORT    =    0xFF22    ; Color computer i/o port address
  8. IMASK    =    1    ; Bit position of input bit in port
  9. ;
  10. ;+
  11. ;    input call to receive a character
  12. ;-
  13. serinp:
  14.     .byte    0x1A,0x50    ;orcc 50, kill interrupts
  15.     bsr    inwait        ;get character
  16.     clr    b
  17.     .byte    0x1E,0x89    ;Exg B,A
  18.     rts            ;exit, character in b
  19. ;
  20. ;+
  21. ;    inwait    waits for an input character to start and
  22. ;    receives it.
  23. ;-
  24. inwait:
  25.     mov    IPORT,a
  26.     and    $IMASK,a        ; Get the bit out
  27.     beq    inwait        ; wait on line = 0 
  28. ;
  29. serget:
  30.     .byte    0x34,0x34    ;PSHS X,Y,B
  31.     .byte    0x10,0x8E,0,8    ;LDY #8 = bitcounter
  32.     .byte    0x8E
  33.     .word    halfbit    ;LDX bitime /2 
  34.     clr    a        ; clear receive register
  35. ;+
  36. ;    sync up on the start bit transition
  37. ;-
  38. sync:
  39.     mov    IPORT,b    ;get port value
  40.     and    $IMASK,b        ;Test bit value
  41.     bne    sync        ;wait on start bit = 1
  42. start:
  43.     .byte    0x30,0x1F    ;LEAX -1,X
  44.     beq    assemble    ;one half bit time has expired
  45.     mov    IPORT,b
  46.     and    $IMASK,b
  47.     beq    start        ;count down the start bit
  48.     mov    $-1,a        ; Glitch on start,return error
  49.     .byte    0x35,0x34    ;PULS X,Y,B
  50.     rts            ;error exit
  51. assemble:
  52.     .byte    0x8E
  53.     .word    bitime        ; set one bit time wait
  54. assemb1:
  55.     .byte    0x30,0x1F    ; LEAX -1,x ,dec bit timer
  56.     bne    assemb1
  57.     mov    IPORT,b
  58.     and    $IMASK,b
  59.     beq    assemb2
  60.     or    $0x80,a        ; or in the bit
  61. assemb2:
  62.     .byte    0x31,0x3F    ;LEAY -1,Y decr. bit count
  63.     beq    seriox        ; exit if done
  64.     lsr    a        ; move the bit down for the next pass
  65.     bra    assemble
  66. seriox:
  67.     .byte    0x35,0x34    ;PULS X,Y,B
  68.     rts            ; character in A
  69. ter in A
  70. cracter